import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import local_set from '@dfeidao/atom-mobile/local/set';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import alert from '@dfeidao/atom-mobile/msgbox/alert';
import render from '@dfeidao/atom-mobile/render/render';
import whoami_getparams from '../atom/whoami_getparams';


export default async function a001(fd: IFeidaoAiMobile) {

	const user = await whoami_getparams(fd) as { userinfo: { productid: string; }, params: { teacher_name: string, teacher_no: string, productid: string } };
	if (!user.userinfo.productid) {
		alert('请先登录！');
		return;
	}
	// .系统参数:username:"教师姓名",usercode:"教师编号"
	const page_no = 1;
	const teacher_no = user.params.teacher_no;
	const teacher_name = user.params.teacher_name;
	const productid = user.params.productid;
	await local_set(fd, 'teacher_no', teacher_no);
	await local_set(fd, 'teacher_name', teacher_name);

	await local_set(fd, 'productid', productid);
	const task_data = await nodejs<Array<{}>>('app-arrange-homework/s001', { filter: { teacher_no }, productid, page_no });
	await local_set(fd, 'task_data', task_data);
	if (task_data.length === 0) {
		render(fd, { wushujv: "yes", task_data: [] });
	} else {
		render(fd, { dt: task_data, page_no, new_len: task_data.length });
	}
}
